﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Ochkin.SquaredSoccer.Base;

namespace Ochkin.SquaredSoccer.UnitTest
{
    /// <summary>
    /// Summary description for UnitTest1
    /// </summary>
    [TestClass]
    public sealed class SpotTest
    {
        [TestMethod]
        public void ShiftTest()
        {
            //
            // TODO: Add test logic here
            //
            Spot a = new Spot(0, 0);
            Spot b;

            b = Shift(a, Direction.NewMix(SideOfEarth.North, SideOfEarth.East));
            Assert.AreEqual<Spot>(new Spot(1, 1), b);

            var dirs = new Direction[] {
                Direction.NewMix(SideOfEarth.South, SideOfEarth.West),
                Direction.NewSimple(SideOfEarth.East),
                Direction.NewMix(SideOfEarth.North, SideOfEarth.East),
                Direction.NewSimple(SideOfEarth.South),
                Direction.NewMix(SideOfEarth.South, SideOfEarth.West),
                Direction.NewMix(SideOfEarth.South, SideOfEarth.East),
                Direction.NewSimple(SideOfEarth.North)
            };
            b = Shift(a, dirs);
            Assert.AreEqual<Spot>(new Spot(1, -2), b);
        }

        private static Spot Shift(Spot spot, Direction dir)
        {
            PrivateObject privateObject = new PrivateObject(spot);
            var result = privateObject.Invoke("Shift", new Type[] { typeof(Direction) }, new object[] { dir });
            return (Spot)result;
        }

        private static Spot Shift(Spot spot, IEnumerable<Direction> dirs)
        {
            PrivateObject privateObject = new PrivateObject(spot);
            var result = privateObject.Invoke("Shift", new Type[] { typeof(IEnumerable<Direction>) }, new object[] { dirs });
            return (Spot)result;
        }
    }
}
